package shan.rpc.yurpc.server;

import io.vertx.core.Vertx;

public class VertxHttpServer implements HttpServer{

    public void dostart(int port){
        //创建Vertx实例
        Vertx vertx=Vertx.vertx();

        //创建Http服务器
        io.vertx.core.http.HttpServer server=vertx.createHttpServer();

        //监听端口并处理请求
        server.requestHandler(new HttpServerHandler());

        server.listen(port,res->{
            if(res.succeeded()){
                System.out.println("Http Server now started on port "+port);
            }else{
                System.out.println("Failed to start Http Server"+res.cause());
                res.cause().printStackTrace();
            }
        });
    }
}
